package com.zhou.spring.test_001;

import com.zhou.spring.test_001.A;
import com.zhou.spring.test_001.B;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author zhouyanxiang
 * @create 2020-07-2020/7/13-18:02
 */
public class SpringTest {
    public static void main(String[] args) {
//        A a = new A();
//        B b = new B();
//        C c = new C();
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
        A a =  ctx.getBean("A",A.class);
        System.out.println(ToStringBuilder.reflectionToString(a));
        System.out.println(ToStringBuilder.reflectionToString(a.getB()));
        System.out.println(ToStringBuilder.reflectionToString(a.getB().getC()));

        System.out.println("--------------------");

        A a1 =  ctx.getBean("A",A.class);
        System.out.println(ToStringBuilder.reflectionToString(a1));
        System.out.println(ToStringBuilder.reflectionToString(a1.getB()));
        System.out.println(ToStringBuilder.reflectionToString(a1.getB().getC()));

        System.out.println("=====================");
        System.out.println("=====================");


        B b =  ctx.getBean("B",B.class);
        System.out.println(ToStringBuilder.reflectionToString(b));
        System.out.println(ToStringBuilder.reflectionToString(b.getC()));
        System.out.println(ToStringBuilder.reflectionToString(b.getC().getA()));

        System.out.println("-----------------------------");

        B b1 =  ctx.getBean("B",B.class);
        System.out.println(ToStringBuilder.reflectionToString(b1));
        System.out.println(ToStringBuilder.reflectionToString(b1.getC()));
        System.out.println(ToStringBuilder.reflectionToString(b1.getC().getA()));
    }
}
